#include<bits/stdc++.h>
#define N 100010
#define pii pair<int,int>
using namespace std;

int T,n,m,L,V,ans=0,ans1=0;
int p[N];
bool vis[N];
vector<pii> b;

struct node{
    int d,v,a,st,nd;
}a[N];

inline void init(){
    memset(vis,0,sizeof vis);
    for(int i=1;i<=n;i++) a[i].st=a[i].nd=0;
    ans=0,ans1=0; b.clear();
    return ;
}

inline void subtask1(){
    for(int i=1;i<=n;i++) 
        if(a[i].v>V && a[i].d<=p[m]) ans++;
    if(ans==0) ans1=m;
    else ans1=m-1;
    cout<<ans<<" "<<ans1<<'\n';
    return ;
}

inline void work(){
    cin>>n>>m>>L>>V;
    init();
    for(int i=1;i<=n;i++) cin>>a[i].d>>a[i].v>>a[i].a;
    for(int i=1;i<=m;i++) cin>>p[i];

    if(n>3000){
        subtask1();
        return ;
    }
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            if(p[i]<a[j].d) continue;
            int tmp=a[j].v*a[j].v+2*a[j].a*(p[i]-a[j].d);
            if(tmp>V*V){
                vis[j]=true; 
                if(!a[j].st) a[j].st=i;
                a[j].nd=i;
            }
        }
    }
    for(int i=1;i<=n;i++){
        ans+=vis[i]; 
        if(a[i].st && a[i].nd) b.push_back(make_pair(a[i].st,a[i].nd));
    }
    sort(b.begin(),b.end());
    int pst=b[0].first,pnd=b[0].second,cnt=0;
    for(int i=1;i<b.size();i++){
        if(b[i].first>pnd){
            pst=b[i].first; pnd=b[i].second;
            cnt++;
        }
        else{
            pst=min(pst,b[i].first); pnd=min(pnd,b[i].second);
        }
    }
    if(b.size()) cnt++; 
    ans1=m-cnt;
    cout<<ans<<" "<<ans1<<'\n';
    // for(int i=1;i<=n;i++) cout<<a[i].st<<":"<<a[i].nd<<'\n';
    return ;
}

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>T; 
    // T=10;
    while(T--) work();
    return 0;
}